﻿@model BudgetMealsUI.Models.ListViewModel<BudgetMealsModels.Entities.Recipe>
@{
    ViewBag.Title = "All Recipes";
}

@if (Session["CurrentUser"] != null)
{
    @Html.ActionLink("New Recipe", "Edit", new { userID = HttpContext.Current.Session["CurrentUser"] })<br />
}
@if (Model.PageItems.Count() > 0)
{
    foreach (var recipe in Model.PageItems)
    {
        <div style="width: 100%; display: block; clear: both; margin: 10px 0px; height: 149px; overflow: hidden;">
            <div style="float: left; position: relative;">
                <img height="150" width="150" src="@Url.Action("GetImage", "Recipe", new{recipeId=recipe.RecipeID, image=0})" alt="recipeImage"/>
                <div style="font-size: 18px; line-height: 30px; height: 30px; text-align: center; position: absolute; left: 0px; bottom: 0px; background-color: white; opacity: .75; width: 150px;">
                    @{ Html.RenderPartial("Rating", recipe.Rating); }
                </div>
            </div>
            <div id="allRecipes" style="float: left; margin-left: 5px;">
                <h4>
                @Html.ActionLink(recipe.Name, "ShowRecipe", "Recipe", new { Id = recipe.RecipeID}, null) by @Html.ActionLink(@recipe.UserCreated, "Profile", "User", new { id = recipe.UserCreatedID}, null)
                </h4>
                <div>@recipe.Ingredients.Count Ingredients totaling at $@recipe.Cost.ToString("N2")</div>
                <div style="float: right; width: 650px;">
                    @Html.Raw(recipe.Summary)
                </div>
            </div>
        </div>
    }
    <div class="ClearFix"></div>
    <br />
    <div id="pager">
        @Html.PageLinks(Model.Info, x => Url.Action("AllRecipes", new { page = x }))
    </div>
}
else
{
    @: there are no Recipes   
}
